package com.sxhyll.web;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import javax.validation.Valid;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.context.request.WebRequest;

import com.sxhyll.pojo.Test;
import com.sxhyll.web.tags.component.Paginate;


@Controller
public class HomeAction {

	@RequestMapping(value="/", method=RequestMethod.GET)
	public String home(@RequestParam(required = false, value = "pageNo", defaultValue = "1") int pageNo, Model model){
		Paginate paginate = new Paginate(pageNo, 10);
		ArrayList<String> list = new ArrayList<String>();
		list.add(new String("aaaaa"));
		paginate.setPageList(list);
		paginate.setTotalCount(100);
		model.addAttribute("paginate", paginate);
		model.addAttribute("test", new Test());
		return "index";
	}
	@RequestMapping(value="/test", method=RequestMethod.GET)
	public String test(Model model){
		model.addAttribute("test", new Test());
		return "test";
	}
	@RequestMapping(value="/test", method=RequestMethod.POST)
	public String test(@Valid Test test, BindingResult results){
		if(results.hasErrors()){
			return "test";
		}
		return "redirect:/";
	}
}
